﻿@inherits TestComponentBase

<Fixture Test="ThemedButtonUsesClassPassedByCascadingValue">
    <ComponentUnderTest>
        <CascadingValue Value=@(new ThemeInfo { Value = cssClass })>
            <ThemedButton>Click ME!</ThemedButton>
        </CascadingValue>
    </ComponentUnderTest>
</Fixture>
@code {
    string cssClass = "BUTTON";

    void ThemedButtonUsesClassPassedByCascadingValue()
    {
        var cut = GetComponentUnderTest();

        cut.Find("button").ClassList.ShouldContain(cssClass);
    }
}

<Fixture Test="ThemedButtonUsesNamedCascadingValue">
    <ComponentUnderTest>
        <CascadingValue Name=@nameof(ThemedElement.Class)
                        Value=@(new ThemeInfo { Value = "FOO" })>
            <CascadingValue Name=@nameof(ThemedElement.Title)
                            Value=@(new ThemeInfo { Value = "BAR" })>
                <ThemedElement />
            </CascadingValue>
        </CascadingValue>
    </ComponentUnderTest>
</Fixture>
@code {
    void ThemedButtonUsesNamedCascadingValue()
    {
        var cut = GetComponentUnderTest();

        var elm = cut.Find("div");
        elm.ClassList.ShouldContain("FOO");
        elm.GetAttribute("title").ShouldContain("BAR");
    }
}